package com.ebs.md.api;

/**
 * Perforce Revision:
 *  $File: //depot/MarketData/commons-md-api/MAIN/src/main/java/com/ebs/md/api/IOrderBook.java $
 *  $Revision: #3 $  $Change: 114604 $  $DateTime: 2012/09/02 11:22:42 $  $Author: Arik.Sher $
 */

import java.util.List;

/**
 * 
 * @author asher
 *
 * @param <BE> Book Entry
 */
public interface IOrderBook<BE extends IBookEntry>
{
	public IProduct         getProduct();
	
	public List<BE> getAllBids  ();
	
	public List<BE> getAllOffers();
	
	public List<Rate> getTopBidRates  (int maxItems);
	
	public List<Rate> getTopOfferRates(int maxItems);
	
	public List<BE> getTopBidsAtRate  (Rate rate, int maxItems);
	
	public List<BE> getTopOffersAtRate(Rate rate, int maxItems);
	
	/**
	 * 
	 * @return Best(Top) Bid   Rate. if none than return null
	 */
	public Rate getBestBid();
	
	/**
	 * 
	 * @return Best(Top) Offer Rate. if none than return null
	 */
	public Rate getBestOffer();

	/**
	 * @return Worst(Bottom) Bid Rate.  
	 *         return null, when (getBidRatesCount() == 1) or (WorstBid==BestBid)
	 *         
	 * @see BestBid
	 */
	public Rate getWorstBid();

	/**
	 * @return Worst(Bottom) Offer Rate.  
	 *         return null, when (getOfferRatesCount() == 1) or (WorstOffer==BestOffer)
	 * 
	 * @see BestOffer
	 */
	public Rate getWorstOffer();
	
	public int  getBidRatesCount();

	public int  getOfferRatesCount();

	public int  getBidEntriesCountAtRate(Rate rate);

	public int  getOfferEntriesCountAtRate(Rate rate);

	
	/**
	 * 
	 * @param side
	 * @param rate - rate to refer
	 * @return Next Best Rate(not better one)
	 * 
	 * for example for given Rate 1.23, on Offer side, possible returned value is 1.25
	 * for example for given Rate 1.23, on Bid   side, possible returned value is 1.21
	 */
	public Rate getNextBestRate(BookSide side, Rate rate);
	
	/**
	 * @see getNextBestRate
	 */
	public Rate getNextBestBid(Rate rate);
	
	/**
	 * @see getNextBestRate
	 */
	public Rate getNextBestOffer(Rate rate);
	

}
